package com.alpha.common.controller;

import com.alpha.core.http.Response;
import com.alpha.service.utils.MyBatisPlusUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenruwan
 * @since 2022-01-01
 */
@Tag(name = "微服务管理")
@RestController
@RequiredArgsConstructor
public class ServiceController {
    private final DiscoveryClient discoveryClient;

    @GetMapping("/services")
    @Operation(summary = "查询服务列表")
    public Response<IPage<String>> query() {
        return Response.success(MyBatisPlusUtils.buildPage(discoveryClient.getServices()));
    }
}
